package cn.spike.rockcc.service.impl;

import cn.spike.rockcc.domain.AlipayInfo;
import cn.spike.rockcc.domain.PayFlow;
import cn.spike.rockcc.domain.PayOrder;
import cn.spike.rockcc.dto.PayParamDto;
import cn.spike.rockcc.service.IAlipayInfoService;
import cn.spike.rockcc.service.IThirdPartyPaymentService;
import cn.spike.rockcc.utils.AliPayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author:spike
 * @create:2023-03-22 18:34
 */
@Service
public class ThirdPartyPaymentServiceImpl implements IThirdPartyPaymentService {

    @Autowired
    private IAlipayInfoService alipayInfoService;

    @Override
    public String thirdPartApply(String payType,PayOrder payOrder) {
        switch (payType){
            case PayParamDto.AliPay:
                AlipayInfo alipayInfo = alipayInfoService.selectById(2);
                return AliPayUtils.createAliPay(payOrder, alipayInfo);
            case PayParamDto.WxPay:

                return "1";

            case PayParamDto.YHKPay:

                return "2";
        }

        return null;
    }

    @Override
    public void thirdPartRefund(Integer payType,PayFlow payFlow) {
        switch (payType){
            case 1:
                AlipayInfo alipayInfo = alipayInfoService.selectById(2);
                AliPayUtils.drawback(payFlow);
                return;
            case 2:

                return;

            case 3:

                return;
        }

        return;
    }
}
